import App from './App'
import store from './store';
import db from '/static/script/db.js';
import utils from '/static/script/utils.js'
import config from '/static/script/config';

function updateWalletInfo() {
	const address = uni.getStorageSync('wallerAddress');
	const chainId = uni.getStorageSync('chainId'); 
	if (address != undefined && address != null && chainId != undefined && chainId != undefined) {
		return this.$store.dispatch('fetchInfo', {
			address,
			chainId
		});
	} else {
		return Promise.reject('Address or ChainId is missing');
	}
}
uni.$db = db;
// #ifndef VUE3
import Vue from 'vue'
import './uni.promisify.adaptor'
Vue.prototype.$utils = utils
Vue.prototype.$config = config
Vue.prototype.$updateWalletInfo = updateWalletInfo
Vue.config.productionTip = false
App.mpType = 'app'
const app = new Vue({
	store,
	render: h => h(App)
		...App
})
app.$mount()
// #endif

// #ifdef VUE3
import {
	createSSRApp
} from 'vue'
export function createApp() {
	const app = createSSRApp(App)
	app.use(store);
	app.config.globalProperties.$utils = utils;
	app.config.globalProperties.$config = config;
	app.config.globalProperties.$updateWalletInfo = updateWalletInfo;
	return {
		app
	}
}
// #endif